package m.store.model;

import m.base.model.StoreInfo;
import m.base.model.UserInfo;
import m.common.model.*;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;

import java.util.List;
import java.util.stream.Collectors;

@TableMeta(name="ts_month_record",description="月度记录")
public class MonthRecord extends Model implements MigrationModel {
    @Override
    public List<String> migrationOidList(String storeOid) throws Exception {
        return ModelQueryList.getModelList(this.getClass(),new String[]{"oid"},null,
                        QueryCondition.eq("store.oid",storeOid))
                .stream().map(Model::getOid).collect(Collectors.toList());
    }
    @LinkTableMeta(name="store_oid",table= StoreInfo.class,description="所属商户")
    private StoreInfo store;
    @LinkTableMeta(name="user_oid",table= UserInfo.class,description="用户")
    private UserInfo user;
    @FieldMeta(name = "c_year_month",type = FieldType.STRING,length = 20,description = "年月")
    private String yearMonth;
    public final static String YearMonth_Format="yyyy-MM";
    @FieldMeta(name="type",type= FieldType.STRING,description="类型",length = 10,dictOption = "R:入库,C:出库,P:付款,I:收款")
    private String type;
    public final static String Type_Stock="R";
    public final static String Type_Sale="C";
    public final static String Type_Pay="P";
    public final static String Type_Income="I";
    @FieldMeta(name="n_amount",type= FieldType.DOUBLE,defaultValue = "0",description="金额")
    private Double amount;
    @FieldMeta(name="n_num",type= FieldType.INT,defaultValue = "0",description="数量")
    private Integer num;

    public StoreInfo getStore() {
        return store;
    }

    public void setStore(StoreInfo store) {
        this.store = store;
    }

    public UserInfo getUser() {
        return user;
    }

    public void setUser(UserInfo user) {
        this.user = user;
    }

    public String getYearMonth() {
        return yearMonth;
    }

    public void setYearMonth(String yearMonth) {
        this.yearMonth = yearMonth;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }
}
